from django.db import models

from api.utils.enums import OrderType


class Order(models.Model):
    user = models.ForeignKey("User", on_delete=models.CASCADE, related_name="orders")
    status = models.CharField(
        help_text="订单状态",
        choices=OrderType.to_choices(),
        default=OrderType.TO_PIAD.value,
        max_length=256,
    )


class OrderLines(models.Model):
    order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name="lines")
    product = models.ForeignKey("Product", on_delete=models.CASCADE, related_name="order_lines")
    quantity = models.PositiveIntegerField(help_text="商品数量", default=0)
    price = models.PositiveIntegerField(help_text="商品总价", default=0)
